package com.dmlll.service.impl;

import com.dmlll.dao.FamilyMemberMapper;
import com.dmlll.pojo.FamilyMember;
import com.dmlll.service.FamilyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class FamilyServiceimpl implements FamilyService{
    /**
     *
     */
    @Autowired
    private FamilyMemberMapper familyMemberMapper;


    @Override
    public Integer submitFamilyMember(FamilyMember[] familyMembers) {
        int result = 0;
        for (int i = 0; i < familyMembers.length; i++) {
            if(familyMembers[i].getId()==0){
                result+=familyMemberMapper.insertSelective(familyMembers[i]);
            }else {
                familyMemberMapper.updateByPrimaryKeySelective(familyMembers[i]);
            }
        }
        return result;
    }

    @Override
    public List<FamilyMember> getFamilyMemberByPersonalId(Integer personalId) {
        return familyMemberMapper.selectByPersonalId(personalId);
    }
}
